package com.canbot.u05.activity.base

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.canbot.u05.R
import com.canbot.u05.activity.BaseActivityNoTitle
import kotlinx.android.synthetic.main.base_voice_set.*

/**
 * Created by zmp on 2019/6/4 10:58
 * @author zmp
 * 空闲状态待机点选择界面
 */
class BaseVoiceSetActivity : BaseActivityNoTitle(), View.OnClickListener {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.base_voice_set)
        initViews()
    }

    private fun initViews() {
        back_btn_head.setOnClickListener(this)
        systemVoiceIv.setOnClickListener(this)
        customVoiceIv.setOnClickListener(this)
    }

    override fun onClick(v: View) {
        when (v.id) {
            R.id.back_btn_head -> {
                finish()
            }
            R.id.systemVoiceIv -> {
                setResult(BaseMediaSetActivity.SYSTEM_CODE)
                finish()
            }
            R.id.customVoiceIv -> {
                startActivityForResult(Intent(this, BaseCustomAudioActivity::class.java), AUDIO_CODE)
            }
        }
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (resultCode == Activity.RESULT_OK) {
            if (requestCode == AUDIO_CODE ) {
                setResult(Activity.RESULT_OK, data)
                finish()
            }
        }
    }


    companion object {
        const val AUDIO_CODE = 1001
        const val AUDIO_TYPE_KEY = "audioType"
        const val AUDIO_SIMPLE_NAME_KEY = "audioName"
        const val AUDIO_PATH_OR_CONTENT = "audioPathOrContent"
    }
}